package com.jpetrinet.core;

import com.jpetrinet.core.exceptions.NodesWithSameTypeException;

public class Arc extends Object {

	public enum ArcType {Normal, Test, Inhibitor};
	
	private Node source;
	private Node target;
	private ArcType type;
	
	public Arc(String id, Node source, Node target) throws NodesWithSameTypeException {
		if ((source instanceof Transition && target instanceof Transition) ||
				(source instanceof Place && target instanceof Place)) {
			throw new NodesWithSameTypeException();
		}			
		
		this.setId(id);
		this.source = source;
		this.target = target;
		this.type = ArcType.Normal;
	}
	
	public Arc(String id, Node source, Node target, ArcType type) throws NodesWithSameTypeException {
		if ((source instanceof Transition && target instanceof Transition) ||
				(source instanceof Place && target instanceof Place)) {
			throw new NodesWithSameTypeException();
		}			
		
		this.setId(id);
		this.source = source;
		this.target = target;
		this.type = type;
	}	

	public Node getSource() {
		return source;
	}

	public void setSource(Node source) {
		this.source = source;
	}

	public Node getTarget() {
		return target;
	}

	public void setTarget(Node target) {
		this.target = target;
	}

	public ArcType getType() {
		return type;
	}

	public void setType(ArcType type) {
		this.type = type;
	}
}
